<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"
%><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"
%><%@ taglib prefix="security" uri="http://www.springframework.org/security/tags"
%><%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"
%><%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"
%>
<head>
    <title><fmt:message key="category" /></title>
</head>
<body>
    <h1><fmt:message key="category" /></h1>
    <c:url var="createUrl" value="/domain/category/create"/>
    <form:form action="${createUrl}" id="categoryForm" modelAttribute="categoryForm" >
        <form:errors cssClass="error"/>
        <table>
            <form:hidden path="category.inode"/>
            <tbody>
                <tr>
                    <th><fmt:message key="category_parentInode" /> *</th>
                    <td>
						<c:if test="${empty categoryForm.category.parentNode}">
							<form:select path="category.parentInode" >
								<form:option value="-1" label="------" />
								<form:options items="${parentFolderList}" itemValue="inode" itemLabel="title" />
							</form:select>
							<script type="text/javascript">
								Spring.addDecoration(new Spring.ElementDecoration({
									elementId : "category.parentInode",
									widgetType : "dijit.form.FilteringSelect",
									widgetAttrs : {
										required : true
									}
								}));
							</script>
						</c:if>
						<c:if test="${not empty categoryForm.category.parentNode}">
							<form:hidden path="category.parentInode" />
							<c:out value="${categoryForm.category.parentNode.inode} - ${categoryForm.category.parentNode.title}" />
						</c:if>
                        <form:errors cssClass="error" path="category.parentInode"/>
                    </td>
                </tr>

                <tr>
                    <th><fmt:message key="category_title" /> *</th>
                    <td>
                        <form:input path="category.title"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "category.title",
                                widgetType : "dijit.form.ValidationTextBox",
                                widgetAttrs : {
                                    required : true,
									maxLength: 120
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="category.title"/>
                    </td>
                </tr>
                <tr>
                    <th><fmt:message key="category_friendlyName" /> *</th>
                    <td>
                        <form:input path="category.friendlyName"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "category.friendlyName",
                                widgetType : "dijit.form.ValidationTextBox",
                                widgetAttrs : {
                                    required : true,
									maxLength: 120
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="category.friendlyName"/>
                    </td>
                </tr>
                <tr>
                    <th><fmt:message key="category_showOnMenu" /></th>
                    <td>
                        <form:checkbox id="category.showOnMenu" path="category.showOnMenu"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "category.showOnMenu",
                                widgetType : "dijit.form.CheckBox",
                                widgetAttrs : {
                                    checked: ${categoryForm.category.showOnMenu != null ? categoryForm.category.showOnMenu : false}
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="category.showOnMenu"/>
                    </td>
                </tr>
                <tr>
                    <th><fmt:message key="category_sortOrder" /></th>
                    <td>
                        <form:input path="category.sortOrder"/>
                        <script type="text/javascript">
                            Spring.addDecoration(new Spring.ElementDecoration({
                                elementId : "category.sortOrder",
                                widgetType : "dijit.form.ValidationTextBox",
                                widgetAttrs : {
                                    required : false
                                    ,regExp : "[-+]?[0-9]+(\.[0-9]+)?"
                                }
                            }));
                        </script>
                        <form:errors cssClass="error" path="category.sortOrder"/>
                    </td>
                </tr>
            </tbody>
            <tfoot>
                <tr>
                    <td colspan="2">
                        <div class="buttons">
                            <button id="saveButton" class="ok" type="submit"><fmt:message key="label.form.submit"/></button>
                            <script type="text/javascript">
                                Spring.addDecoration(new Spring.ValidateAllDecoration({
                                    elementId:'saveButton',
                                    event:'onclick'
                                }));
								<c:if test="${not empty ajaxRequest}">
								Spring.addDecoration(new Spring.AjaxEventJsonDecoration({
									elementId:'saveButton',
									event:'onclick',
									formId:'categoryForm',
									params: { decorator: "none", successTopic: "NewFolderItemCreated"}
								}));
								</c:if>
                            </script>
                        </div>
                    </td>
                </tr>
            </tfoot>
        </table>
    </form:form>
</body>
